import { Stencil } from '@antv/x6-plugin-stencil'
import './register.js'
import { EType } from './config.js'

function createStencil(graph, vm) {
  const stencil = new Stencil({
    title: '流程图',
    target: graph,
    // stencilGraphWidth: 100,
    stencilGraphHeight: 0,
    collapsable: true,
    // resizeToFit:true,
    groups: [
      {
        title: '设备图例',
        name: 'group1',
        graphHeight: 0,
        layoutOptions: {
          rowHeight: 180,
        }
      }
    ],

    layoutOptions: {
      columns: 2,
      columnWidth: 140,
      dy: -30,
      // resizeToFit:true
    }
  })
  document.getElementById('stencil').appendChild(stencil.container)


  const L = [
    {
      shape: EType.Car.alias,
    },
    {
      shape: EType.Export.alias,
    },
    {
      shape: EType.Entrance.alias,
    },
    {
      shape: EType.Electrical.alias,
    },
    {
      shape: EType.RoundEdge.alias,
    },
    {
      shape: EType.SmoothEdge.alias,
    },
    {
      shape: EType.Line.alias,
    },
    {
      shape: EType.Document.alias,
    },

  ]
  const arr = []
  for (const i of L) {
    arr.push(graph.createNode(i))
  }

  stencil.load(arr, 'group1')

  return stencil
}

export default createStencil
